package cn.ld.fj.service.vip;

import cn.ld.fj.dao.order.MealOrderDao;
import cn.ld.fj.dao.vip.VipUserDao;
import cn.ld.fj.entity.MealOrder;
import cn.ld.fj.entity.VipUser;
import net.esoar.modules.orm.Page;
import net.esoar.modules.orm.PropertyFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 安全相关实体的管理类, 包括用户,角色,资源与授权类.
 *
 * @author fly
 */
//Spring Bean的标识.
@Component
//默认将类中的所有函数纳入事务管理.
@Transactional
public class VipUserManager {

    private static Logger logger = LoggerFactory.getLogger(VipUserManager.class);
    @Autowired
    private VipUserDao vipUserDao;


    @Transactional(readOnly = true)
    public VipUser getOne(Long id) {
        return vipUserDao.get(id);
    }

    public void save(VipUser entity) {
        vipUserDao.save(entity);
    }


    public Page<VipUser> getPage(Page<VipUser> page, List<PropertyFilter> filters) {
        return vipUserDao.findPage(page, filters);
    }

    public void delete(Long id) {
        vipUserDao.delete(id);
    }

    @Transactional(readOnly = true)
    public VipUser getOneByCardNum(String cardNum) {
        return vipUserDao.findUniqueBy("cardNo", cardNum);
    }
}
